package com.wis.mapper;

import com.wis.entity.CourseEntity;
import com.wis.util.CommonResult;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseMapper {
    // 分页查询
    @Select("SELECT * FROM course WHERE name LIKE CONCAT('%', #{name}, '%') LIMIT #{limit} OFFSET #{offset}")
    List<CourseEntity> findBlurry(@Param("name") String name, @Param("limit") int limit, @Param("offset") int offset);

    @Insert("INSERT INTO course (name, content, type, status, old_money, in_money, out_money, section_number) " +
            "VALUES (#{name}, #{content}, #{type}, #{status}, #{oldMoney}, #{inMoney}, #{outMoney}, #{sectionNumber})")
    int addCourse(CourseEntity course);

    @Update("UPDATE course SET name = #{name}, content = #{content}, type = #{type}, status = #{status}, " +
            "old_money = #{oldMoney}, in_money = #{inMoney}, out_money = #{outMoney}, section_number = #{sectionNumber} " +
            "WHERE id = #{id}")
    int updateCourse(CourseEntity course);
    // 删除课程
    @Delete("DELETE FROM course WHERE id = #{id}")
    int delCourse(@Param("id") int id);


}
